/******************************************************************************
 * * sms_receive.c - implementation of sms receive functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "sms_include.h"

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox(lv_obj_t *pBtn,lv_event_t event)
{
    // Inbox function
    // read received messages
    // create Messages_Opening chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = Sms_Inbox_Timeout;
//    Msg_Content_Info_t                     *pNode = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));
    g_MsgGlobalCtrl.CurOpenBox = MSG_INBOX;

    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pInboxMsgContentInfo)
    {    // inbox has been read
        // 2s timer start
        printf("pInboxMsgContentInfo is not null in Sms_Inbox\n");
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
    }
    else
    {
        printf("Read_Sms_Info_Req is called\n");
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }
} /* Sms_Inbox */

/**
 * sub-module entry
 * param (in)
 * return  VOID
 */
VOID Sms_Inbox_Timeout(VOID* id)
{
    // create Messages_Inbox chart
    UINT32* Id = (UINT32 *)id;
    printf("Sms_Inbox_Timeout is called\n");
    Sms_Inbox_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_List(UINT32 id)
{
    // Inbox messages list function
    // create Messages_Inbox chart
    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pInbox     = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    Msg_Content_Info_t         *pTemp      = NULL;

    pInbox = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pInbox, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pInbox;

    pInbox->TitleBar.TxtId      = PHONE_TEXT_ID_INBOX;
    pInbox->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pInbox->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pInbox->List.ListButtonCnt = Cnt;
    pInbox->List.Index         = 0;
    pInbox->List.ButtonList    = ButtonList;

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);
        }

        ButtonList[i].ButtonIndex = 0xFF;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = Sms_Inbox_List_Read;
        ButtonList[i].Valid      = true;
    }
    pInbox->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pInbox->BtnBar.ButtonR.Valid = true;

    pInbox->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_READ;
    pInbox->BtnBar.ButtonM.Valid = true;

    pInbox->KeyFunc = Sms_Inbox_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Inbox_On_Create;
    FuncList.OnDestroy      = Sms_Inbox_Destory;   // temp
    FuncList.OnSaveState    = Sms_Common_Save;     // temp
    FuncList.OnRestoreState = Sms_Inbox_On_Create; // temp

    Nav_Forward(id, ACT_ID_MESSAGES_INBOX, &FuncList, (void *)pInbox);
} /* Sms_Inbox_List */

/**
 * Common Process UI create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Inbox_On_Create(VOID *pDesc)
{
    UINT8                      i       = 0;
    UI_Normal_List_Only_Desc_t *pInbox = pDesc;

    g_MsgGlobalCtrl.pChart = pDesc;
    Msg_Content_Info_t *pTemp = NULL;
    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);
    while (NULL != pTemp)
    {
        pInbox->List.ButtonList[i++].Button->user_data.user_data = pTemp;
        pTemp                                         = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
    }
}

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Inbox_Destory(VOID *pDesc)
{
    UI_Normal_List_Only_Desc_t *pInput = pDesc;

    Hal_Mem_Free(pInput->List.ButtonList);
    pInput->List.ButtonList = NULL;
    Sms_Common_All_Global_Destory(pDesc);
}

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Inbox_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Home(ACT_ID_ANY); //for demo
            Sms_Main();//for demo
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);    // temp
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_Empty(VOID)
{
    // Inbox messages list function
    // Messages_Inbox_empty chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pInboxEmpty = NULL;
    CB_FUNC          callback     = Sms_Inbox_Empty_Timeout;

    pInboxEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pInboxEmpty, 0, sizeof(UI_Status_Desc_t));

    pInboxEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pInboxEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_INBOX_EMPTY;
    pInboxEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pInboxEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pInboxEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pInboxEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pInboxEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX_EMPTY, &FuncList, (void *)pInboxEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_INBOX_EMPTY);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_Empty_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    if (0 != g_MsgGlobalCtrl.UnreadCnt)
    {
        g_MsgGlobalCtrl.UnreadCnt = 0;
        printf("g_MsgGlobalCtrl.UnreadCnt is %d in Sms_Inbox_Empty_Timeout\n",g_MsgGlobalCtrl.UnreadCnt);
        Framework_Sms_Unread_Message_Ind(g_MsgGlobalCtrl.UnreadCnt);
    }
    if(g_MsgGlobalCtrl.OtherAppUseType == FRAMEWORK_SMS_OPEN_INBOX_REQ)
    {
        g_MsgGlobalCtrl.OtherAppUseType = 0;
        Nav_Home(*Id);
    }
    else
    {
        Nav_Forward(*Id, ACT_ID_MESSAGES, NULL, NULL);
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_List_Read(lv_obj_t *pBtn,lv_event_t event)
{
    // Inbox messages list function
    // create Messages_Opening chart
    MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *pReadSmsReq;
    Nav_Func_List_t                        FuncList;
    UI_Status_Desc_t                       *pOpening = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    pOpening->ContLabel.LabelAlign = LV_ALIGN_CENTER;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_CENTER;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    g_MsgGlobalCtrl.pCurrentViewMsg = pBtn->user_data.user_data;

    pReadSmsReq = (MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    Hal_Mem_Set(pReadSmsReq, 0, sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    pReadSmsReq->MsgIndex = g_MsgGlobalCtrl.pCurrentViewMsg->MsgIndex;

    pReadSmsReq->SimId = g_MsgGlobalCtrl.pCurrentViewMsg->SimId;

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING2, &FuncList, (void *)pOpening);

    MMI_Modem_Read_Sms_Detail_On_Sim_Req(pReadSmsReq);
} /* Sms_Inbox_List_Read */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_MsgBody(VOID)
{
    // sms inbox body function
    // create Messages_Inbox_Msgbody chart
    Nav_Func_List_t             FuncList;
    UI_Normal_NoTitle_Ta_Desc_t *pReadMsg = NULL;

    pReadMsg = (UI_Normal_NoTitle_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Ta_Desc_t));
    Hal_Mem_Set(pReadMsg, 0, sizeof(UI_Normal_NoTitle_Ta_Desc_t));

    pReadMsg->ContLabelTl.TxtId    = PHONE_TEXT_ID_MEM_STA;
    pReadMsg->ContLabelTl.TxtAlign = LV_LABEL_ALIGN_CENTER;

    pReadMsg->ContLabelTr.TxtId    = LV_LANG_TXT_ID_NONE;
    pReadMsg->ContLabelTr.TxtAlign = LV_LABEL_ALIGN_CENTER;
    pReadMsg->ContTa.TaTxt         = NULL;

    pReadMsg->ButtonBar.ButtonL.TxtId      = PHONE_TEXT_ID_OPT;
    pReadMsg->ButtonBar.ButtonL.ReleaseFun = NULL;
    pReadMsg->ButtonBar.ButtonL.Valid      = true;

    pReadMsg->ButtonBar.ButtonR.TxtId      = PHONE_TEXT_ID_BACK;
    pReadMsg->ButtonBar.ButtonR.ReleaseFun = NULL;
    pReadMsg->ButtonBar.ButtonR.Valid      = true;

    pReadMsg->KeyFunc = Sms_Inbox_MsgBody_Handle;                       // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Inbox_MsgBody_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory;          // temp
    FuncList.OnSaveState    = Sms_Common_Save;             // temp
    FuncList.OnRestoreState = Sms_Inbox_MsgBody_On_Create; // temp

    if (MMI_MODEM_UNREAD == g_MsgGlobalCtrl.pCurrentViewMsg->SmsType)
    {
        g_MsgGlobalCtrl.pCurrentViewMsg->SmsType = MMI_MODEM_READ;
        MMI_Modem_Sms_File_Set_Read_Req(g_MsgGlobalCtrl.pCurrentViewMsg->MsgIndex);
        if (0 != g_MsgGlobalCtrl.UnreadCnt)
        {
            g_MsgGlobalCtrl.UnreadCnt--;
            printf("g_MsgGlobalCtrl.UnreadCnt is %d in %s\n",g_MsgGlobalCtrl.UnreadCnt, __FUNCTION__);
            Framework_Sms_Unread_Message_Ind(g_MsgGlobalCtrl.UnreadCnt);
        }
    }

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX_MSGBODY, &FuncList, (void *)pReadMsg);
} /* Sms_Inbox_MsgBody */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Inbox_MsgBody_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;
    UI_Normal_List_Only_Desc_t *pInbox     = NULL;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            pInbox = (UI_Normal_List_Only_Desc_t*)Nav_Get_Param(ACT_ID_MESSAGES_INBOX);

            Sms_Inbox_Flush_ButtonList(&pInbox->List);

            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX, NULL, (void *)pInbox);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        if (KEY_SOFTLEFT == key_val)
        {
            Sms_Inbox_Opt(obj);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * Common Process UI flush button list
 * param (in) List:  UI_List_Desc_t *
 * return  void
 */
VOID Sms_Inbox_Flush_ButtonList(UI_List_Desc_t *List)
{
    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Msg_Content_Info_t         *pTemp      = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    Hal_Mem_Free(List->ButtonList);
    List->ButtonList = NULL;
    List->ListButtonCnt = 0;
    List->Index         = 0;

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);
        }

        ButtonList[i].ButtonIndex = 0xFF;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = Sms_Inbox_List_Read;
        ButtonList[i].Valid      = true;
    }
    List->ButtonList = ButtonList;
    List->ListButtonCnt = Cnt;
    printf("List->ListButtonCnt is %d in Sms_Inbox_Flush_ButtonList\n",List->ListButtonCnt);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Inbox_MsgBody_On_Create(VOID *pDesc)
{
    UI_Normal_NoTitle_Ta_Desc_t *pReadMsg = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pReadMsg               = g_MsgGlobalCtrl.pChart;

    lv_label_set_text(pReadMsg->ContLabelTl.Label, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    lv_obj_set_style_local_text_font(pReadMsg->ContTa.TextArea,
                                     LV_TEXTAREA_PART_BG,
                                     LV_STATE_DEFAULT,
                                     LV_FONT_PTR_DRIODSANSFALLBACKFULL_SMALL);
    lv_textarea_set_text(pReadMsg->ContTa.TextArea, g_MsgGlobalCtrl.pReadSmsText);
    lv_textarea_set_cursor_pos(pReadMsg->ContTa.TextArea, 0);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Inbox_Opt(lv_obj_t *pBtn)
{
    // sms inbox options function
    // create Messages_Inbox_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pInboxOpt  = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    pInboxOpt = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pInboxOpt, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 7);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 7);

    g_MsgGlobalCtrl.pChart = pInboxOpt;

    pInboxOpt->TitleBar.TxtId      = LV_LANG_TXT_ID_NONE;
    pInboxOpt->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pInboxOpt->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pInboxOpt->List.ListButtonCnt  = 7;
    pInboxOpt->List.Index          = 0;
    pInboxOpt->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_DELETE;
    ButtonList[0].ReleaseFun  = Sms_Inbox_Opt_Delete;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_REPLY;
    ButtonList[1].ReleaseFun  = Sms_Inbox_Opt_Reply;
    ButtonList[1].Valid       = true;
    ButtonList[2].ButtonIndex = 2;
    ButtonList[2].TxtId       = PHONE_TEXT_ID_EDIT;
    ButtonList[2].ReleaseFun  = Sms_Inbox_Opt_Edit;
    ButtonList[2].Valid       = true;
    ButtonList[3].ButtonIndex = 3;
    ButtonList[3].TxtId       = PHONE_TEXT_ID_USE_NUM;
    ButtonList[3].ReleaseFun  = Sms_Inbox_Opt_Use_Num;
    ButtonList[3].Valid       = true;
    ButtonList[4].ButtonIndex = 4;
    ButtonList[4].TxtId       = PHONE_TEXT_ID_FORWARD;
    ButtonList[4].ReleaseFun  = Sms_Inbox_Opt_Forward;
    ButtonList[4].Valid       = true;
    ButtonList[5].ButtonIndex = 5;
    ButtonList[5].TxtId       = PHONE_TEXT_ID_DETAILS;
    ButtonList[5].ReleaseFun  = Sms_Inbox_Opt_Details;
    ButtonList[5].Valid       = true;
    ButtonList[6].ButtonIndex = 6;
    ButtonList[6].TxtId       = PHONE_TEXT_ID_ADD_TO_SL;
    ButtonList[6].ReleaseFun  = Sms_Inbox_Opt_Add_To_Scrn;
    ButtonList[6].Valid       = true;

    pInboxOpt->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pInboxOpt->BtnBar.ButtonR.Valid = true;

    pInboxOpt->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pInboxOpt->BtnBar.ButtonM.Valid = true;

    pInboxOpt->KeyFunc = Sms_Inbox_Opt_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX_OPT, &FuncList, (void *)pInboxOpt);
    lv_label_set_text(pInboxOpt->TitleBar.Label, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);

    return(LV_RES_OK);
} /* Sms_Inbox_Opt */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Inbox_Opt_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }
    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Delete(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options delete function
    // create Messages_Deleted_Confirm. chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDelete = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelete = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDelete, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDelete;

    pDelete->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDelete->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_SMS_Q;
    pDelete->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDelete->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDelete->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelete->ButtonBar.ButtonR.Valid = true;

    pDelete->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDelete->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDelete->ButtonBar.ButtonM.Valid      = true;

    pDelete->KeyFunc = Sms_Inbox_Opt_Delete_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_CONFIRM, &FuncList, (void *)pDelete);
} /* Sms_Inbox_Opt_Delete */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Inbox_Opt_Delete_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Inbox_Opt_Delete_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Inbox_Opt_Delete_OK(lv_obj_t *pBtn)
{
    // sms inbox options delete OK function
    // delete the message
    // create Messages_Deleted_Status chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);
    Sms_Common_Delete_Single_Sms(&g_MsgGlobalCtrl.pInboxMsgContentInfo);
    Sms_Inbox_Opt_Delete_Done(NULL);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pLabel
 * return  lv_res_t
 */
lv_res_t Sms_Inbox_Opt_Delete_Done(lv_obj_t *pLabel)
{
    // sms inbox options delete done function
    // create Messages_Deleted_Done chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteDone = NULL;
    CB_FUNC          callback     = Sms_Inbox_Opt_Delete_Done_Timeout;

    pDeleteDone = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteDone, 0, sizeof(UI_Status_Desc_t));

    pDeleteDone->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteDone->ContLabel.TxtId      = PHONE_TEXT_ID_DELETED;
    pDeleteDone->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteDone->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteDone->ContImg.Img = SYMBOL_CHECKED;

    pDeleteDone->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pDeleteDone->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_DONE, &FuncList, (void *)pDeleteDone);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_DONE);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_Opt_Delete_Done_Timeout(VOID* id)
{
    // sms inbox options delete done function
    // create Messages_Deleted_Done chart
    UINT32* Id = (UINT32 *)id;
    if(g_MsgGlobalCtrl.OtherAppUseType == FRAMEWORK_SMS_OPEN_INBOX_REQ)
    {
        Nav_Home(ACT_ID_ANY);
        g_MsgGlobalCtrl.OtherAppUseType = FRAMEWORK_SMS_OPEN_INBOX_REQ;
        Sms_Inbox(NULL,LV_EVENT_CLICKED);
    }
    else
    {
        Nav_Forward(*Id, ACT_ID_MESSAGES, NULL, NULL);
        Sms_Inbox(NULL,LV_EVENT_CLICKED);
    }
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Reply(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options reply function
    // go to Sms_Create without Ta
    // set the reply special back:Sms_Inbox_Opt_Reply_Back
    UINT32 i = 0;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    // get the reply number to g_MsgGlobalCtrl.pContact
    Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
    g_MsgGlobalCtrl.pSmsText = NULL;
    Hal_Mem_Free(g_MsgGlobalCtrl.pContact);
    i = strlen(g_MsgGlobalCtrl.pCurrentViewMsg->pContact);

    g_MsgGlobalCtrl.pContact = Hal_Mem_Alloc(i + 1);
    strcpy(g_MsgGlobalCtrl.pContact, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    Sms_Create(NULL,LV_EVENT_CLICKED);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Edit(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options edit function
    // go to Sms_Create with Ta
    // set the edit special back:Sms_Inbox_Opt_Edit_Back
    UINT32 i = 0;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    i = strlen(g_MsgGlobalCtrl.pReadSmsText);
    if (i)
    {
        Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
        g_MsgGlobalCtrl.pSmsText = NULL;
        g_MsgGlobalCtrl.pSmsText = Hal_Mem_Alloc(i + 1);
        Hal_Mem_Set(g_MsgGlobalCtrl.pSmsText, 0, i + 1);
        strcpy(g_MsgGlobalCtrl.pSmsText, g_MsgGlobalCtrl.pReadSmsText);
    }
    Hal_Mem_Free(g_MsgGlobalCtrl.pContact);
    g_MsgGlobalCtrl.pContact = NULL;
    Sms_Create(NULL,LV_EVENT_CLICKED);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Use_Num(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options use number function
    // create Messages_Use_No. chart
    // or Messages_Use_No._No_Num
    UINT32                     i   = 0;
    UINT16                     k   = 0;
    INT8                       *pTemp = NULL;
    INT8                       *pTemp2 = NULL;
    INT8                       *pTemp1[460];
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pUseNum    = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pTemp = g_MsgGlobalCtrl.pReadSmsText;

    while (1)
    {
        if ((((*pTemp) <= '9' && (*pTemp) >= '0') || (*pTemp) == '+') && ((*pTemp) != '\0'))
        {
            i = 0;
            pTemp2 = pTemp;
            while (((*pTemp2) <= '9' && (*pTemp2) >= '0') || (*pTemp2) == '+')
            {
                pTemp2++;
                i++;
            }
            if (i)
            {
                pTemp1[k] = Hal_Mem_Alloc(i + 1);
                Hal_Mem_Set(pTemp1[k], 0, i + 1);
                Hal_Mem_Copy(pTemp1[k],pTemp,i);
                pTemp = pTemp + i;
                k++;
            }
        }
        else
        {
            pTemp++;
        }
        if ((*pTemp) == '\0')
        {        // if the end
            break;
        }
    }
    if (0 == k)
    {    // create  Messages_Use_No._No_Num
        Sms_Inbox_Opt_Use_Num_No_Num();
    }
    else
    {    // create Messages_Use_No. chart
        pUseNum = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
        Hal_Mem_Set(pUseNum, 0, sizeof(UI_Normal_List_Only_Desc_t));

        ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * k);
        Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * k);

        g_MsgGlobalCtrl.pChart       = pUseNum;
        pUseNum->TitleBar.TxtId      = PHONE_TEXT_ID_USE_NUM;
        pUseNum->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
        pUseNum->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

        pUseNum->List.ListButtonCnt = k;
        pUseNum->List.Index         = 0;
        pUseNum->List.ButtonList    = ButtonList;

        for (i = 0; i < k; i++)
        {
            ButtonList[i].ButtonIndex = i;
            ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
            ButtonList[i].BtnTxt      = "";
            ButtonList[i].ReleaseFun  = Sms_Inbox_Opt_Use_Num_OK;
            ButtonList[i].Valid       = true;
        }
        pUseNum->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
        pUseNum->BtnBar.ButtonR.Valid = true;

        pUseNum->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
        pUseNum->BtnBar.ButtonM.Valid = true;

        pUseNum->KeyFunc = Sms_Inbox_Opt_Use_Num_Handle;

        FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
        FuncList.OnHide         = NULL;
        FuncList.OnCreate       = Sms_Common_Create;
        FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
        FuncList.OnSaveState    = Sms_Common_Save;              // temp
        FuncList.OnRestoreState = Sms_Common_Restore;           // temp

        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_USE_NUM, &FuncList, (void *)pUseNum);
        for (i = 0; i < k; i++)
        {
            lv_label_set_text((lv_obj_t *)pUseNum->List.ButtonList[i].Button->child_ll.head, pTemp1[i]);
        }
    }
} /* Sms_Inbox_Opt_Use_Num */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_Opt_Use_Num_No_Num(VOID)
{
    // create  Messages_Use_No._No_Num
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pNoNum  = NULL;
    CB_FUNC          callback = Sms_Inbox_Opt_Use_Num_No_Num_Timeout;

    pNoNum = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pNoNum, 0, sizeof(UI_Status_Desc_t));

    pNoNum->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pNoNum->ContLabel.TxtId      = PHONE_TEXT_ID_NO_NUMBERS;
    pNoNum->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pNoNum->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pNoNum->ContImg.Img = LV_SYMBOL_WARNING;

    pNoNum->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pNoNum->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_USE_NUM_NO_NUM, &FuncList, (void *)pNoNum);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_USE_NUM_NO_NUM);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Inbox_Opt_Use_Num_No_Num_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Nav_Back(*Id);
}

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Inbox_Opt_Use_Num_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);    // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Use_Num_OK(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options use number list function
    // get the select number
    // send the number to framework
    UINT32 i       = 0;
    INT8   *pTemp  = NULL;
    INT8   *pTemp1 = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pTemp  = lv_label_get_text(lv_obj_get_child(pBtn, NULL));
    i      = strlen(pTemp);
    pTemp1 = Hal_Mem_Alloc(i + 1);
    Hal_Mem_Set(pTemp1, 0, i + 1);
    strcpy(pTemp1, pTemp);
    Framework_Sms_Dial_Ind(pTemp1);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Forward(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options forward function
    // go to Sms_Create_Send with Ta
    UINT32 i = 0;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    i = strlen(g_MsgGlobalCtrl.pReadSmsText);
    printf("readsms_len is %d\n",i);
    if (i)
    {
        Hal_Mem_Free(g_MsgGlobalCtrl.pSmsText);
        g_MsgGlobalCtrl.pSmsText = NULL;
        g_MsgGlobalCtrl.pSmsText = Hal_Mem_Alloc(i + 1);
        Hal_Mem_Set(g_MsgGlobalCtrl.pSmsText, 0, i + 1);
        strcpy(g_MsgGlobalCtrl.pSmsText, g_MsgGlobalCtrl.pReadSmsText);
    }

    Hal_Mem_Free(g_MsgGlobalCtrl.pContact);
    g_MsgGlobalCtrl.pContact = NULL;

    Sms_Create(NULL,LV_EVENT_CLICKED);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Details(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options details function
    // create Messages_Details chart
    Nav_Func_List_t             FuncList;
    UI_Normal_NoTitle_Ta_Desc_t *pInboxDetails = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pInboxDetails = (UI_Normal_NoTitle_Ta_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Ta_Desc_t));
    Hal_Mem_Set(pInboxDetails, 0, sizeof(UI_Normal_NoTitle_Ta_Desc_t));

    pInboxDetails->ContLabelTl.TxtId    = PHONE_TEXT_ID_MEM_STA;
    pInboxDetails->ContLabelTl.TxtAlign = LV_LABEL_ALIGN_CENTER;

    pInboxDetails->ContLabelTr.TxtId    = LV_LANG_TXT_ID_NONE;
    pInboxDetails->ContLabelTr.TxtAlign = LV_LABEL_ALIGN_CENTER;
    pInboxDetails->ContTa.TaTxt         = NULL;

    pInboxDetails->ButtonBar.ButtonR.TxtId      = PHONE_TEXT_ID_BACK;
    pInboxDetails->ButtonBar.ButtonR.ReleaseFun = NULL;
    pInboxDetails->ButtonBar.ButtonR.Valid      = true;

    pInboxDetails->KeyFunc = Sms_Create_Opt_Handle;                       // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Ta_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Inbox_Opt_Details_On_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DETAILS, &FuncList, (void *)pInboxDetails);
}

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Inbox_Opt_Details_On_Create(VOID *pDesc)
{
    INT8                        *str1          = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SENT_TIME);
    INT8                        str2           = '\n';
    INT8                        *str3          = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SENDER);
    INT8                        *str4          = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_USED_SIM_COLON);
    INT8                        *str5          = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SIM1);
    INT8                        *str6          = UI_Lang_Get_Text_ById(PHONE_TEXT_ID_SIM2);
    UI_Normal_NoTitle_Ta_Desc_t *pInboxDetails = NULL;

    g_MsgGlobalCtrl.pChart = pDesc;
    pInboxDetails          = g_MsgGlobalCtrl.pChart;

    lv_textarea_set_text(pInboxDetails->ContTa.TextArea, str1);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_text(pInboxDetails->ContTa.TextArea, g_MsgGlobalCtrl.pTime);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_text(pInboxDetails->ContTa.TextArea, str3);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_text(pInboxDetails->ContTa.TextArea, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    lv_textarea_add_text(pInboxDetails->ContTa.TextArea, str4);
    lv_textarea_add_char(pInboxDetails->ContTa.TextArea, str2);
    if (MMI_MODEM_SIM_1 == g_MsgGlobalCtrl.pCurrentViewMsg->SimId)
    {
        lv_textarea_add_text(pInboxDetails->ContTa.TextArea, str5);       // SIM1
    }
    else
    {
        lv_textarea_add_text(pInboxDetails->ContTa.TextArea, str6); // SIM2
    }

    lv_label_set_text(pInboxDetails->ContLabelTl.Label, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Inbox_Opt_Add_To_Scrn(lv_obj_t *pBtn,lv_event_t event)
{
    // sms inbox options add to scrn. list function
    // send the number to contacts

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    Contacts_Add_Num_To_Scrn_List_Req(ACT_ID_MESSAGES_INBOX_OPT, g_MsgGlobalCtrl.pCurrentViewMsg->pContact);
}
